//
// Ishtar C++ Utility Library
//
// Task Facility - Work Poller Private Header
//

#ifndef __ISHTAR_TASK_WORK_POLLER_IMPL_H
#define __ISHTAR_TASK_WORK_POLLER_IMPL_H

#include <Ishtar/Ishtar.h>

#if defined( ISHTAR_COMPILER_HAS_PRAGMA_ONCE )
#pragma once
#endif

#include <Ishtar/Concurrent/ConcurrentDualQueue.h>
#include <Ishtar/Task/TaskFwd.h>
#include <Ishtar/Task/WorkExecutorImpl.h>
#include <Ishtar/Task/WorkPoller.h>


namespace Ishtar
{

namespace Task
{

///////////////////////////////////////////////////////////////////////////////
//
// Work Poller
//

class WorkPollerImpl : public WorkExecutorImpl
{
public:

    void Shutdown();

    void Submit( const WorkImplPtr& w );

    Uint Process( Uint sliceTime );

    Uint GetNumReadyWorks() const { return m_readyWorks.UnsafeSize(); }


private:

    //
    // implements WorkExecutorImpl
    //

    void AddReadyWork( const WorkImplPtr& w );


    //
    // Data Members
    //

    typedef ConcurrentDualQueue< WorkImplPtr > WorkQueue;
    WorkQueue m_readyWorks;

};


///////////////////////////////////////////////////////////////////////////////

} // namespace Task

} // namespace Ishtar

#endif // __ISHTAR_TASK_WORK_POLLER_IMPL_H
